[SoftCSA] Fix 100% CPU usage and missing CWs on softcam restart#3709
Merged
jbleyel merged 1 commit intoopenatv:masterfrom Feb 15, 2026
Merged
[SoftCSA] Fix 100% CPU usage and missing CWs on softcam restart#3709jbleyel merged 1 commit intoopenatv:masterfrom
jbleyel merged 1 commit intoopenatv:masterfrom
Conversation
CPU bug: When the softcam restarts, the old socket gets closed but read() returning 0 (EOF) was never handled in the CWHandler poll loop. Additionally, POLLHUP was gated behind !(revents & POLLIN) which fails when both flags are set on a closed socket. This caused an infinite busy-loop: poll() -> read() -> 0 -> ignored -> poll() -> ... Fix: Handle EOF (read==0) for both softcam_fd and proxy_fd paths, and remove the POLLIN gate from POLLHUP/POLLERR handling. CW bug: After softcam reconnect, the running channel never received new CW keys. On reconnect (m_protocol3_established), distributeCAPMT() was called before the Protocol-3 handshake, sending CAPMTs in legacy format. The softcam processed these and started descrambling. The subsequent Protocol-3 CAPMTs after SERVER_INFO were treated as duplicates - no CW keys were sent. Fix: On Protocol-3 reconnect, complete the handshake first before distributing CAPMTs. processServerInfoPacket() already calls distributeCAPMT() after the handshake completes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CPU bug: When the softcam restarts, the old socket gets closed but read() returning 0 (EOF) was never handled in the CWHandler poll loop. Additionally, POLLHUP was gated behind !(revents & POLLIN) which fails when both flags are set on a closed socket. This caused an infinite busy-loop: poll() -> read() -> 0 -> ignored -> poll() -> ...
Fix: Handle EOF (read==0) for both softcam_fd and proxy_fd paths, and remove the POLLIN gate from POLLHUP/POLLERR handling.
CW bug: After softcam reconnect, the running channel never received new CW keys. On reconnect (m_protocol3_established), distributeCAPMT() was called before the Protocol-3 handshake, sending CAPMTs in legacy format. The softcam processed these and started descrambling. The subsequent Protocol-3 CAPMTs after SERVER_INFO were treated as duplicates - no CW keys were sent.
Fix: On Protocol-3 reconnect, complete the handshake first before distributing CAPMTs. processServerInfoPacket() already calls distributeCAPMT() after the handshake completes.
Fixes #3708